package com.trump.baiduim.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.trump.baiduim.dao.MessageDao;
import com.trump.baiduim.dao.UserDao;
import com.trump.baiduim.model.Message;
import com.trump.baiduim.model.User;
import com.trump.baiduim.service.AdminUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author guoyuans
 */
@Service
public class AdminUserImpl implements AdminUser {
    
    @Autowired
    private UserDao userDao;
    
    @Autowired
    private MessageDao messageDao;
    
    @Override
    public List<User> getAllUserInfo(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> result = userDao.getAllUserInfo();
        return result;
    }

    @Override
    public List<Message> queryMessage(Integer pageNum,Integer pageSize,Message message) {
        PageHelper.startPage(pageNum,pageSize);
        List<Message> result = messageDao.queryMessage(message);
        return result;
    }

    @Override
    public void deleteUserInfoByUserAccount(String userAccount) {
        userDao.deleteUserInfoByUserAccount(userAccount);
    }

    @Override
    public void updateUserInfo(User user){
        userDao.updateUserInfo(user);
    }

    @Override
    public User getUserByAccountAndPassword(String userAccount,String password ){
        return userDao.getUserByAccountAndPassword(userAccount,password);
    }
    
}
